﻿using System;
using System.Collections.Generic;
using System.Text;

using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Carto;

namespace shudiangis.Common
{
    /// <summary>
    /// 空间过滤
    /// </summary>
    public class UserSpatialFilter
    {
        /// <summary>
        /// 根据图形进行空间过滤
        /// </summary>
        /// <param name="pGeometry"></param>
        /// <returns></returns>
        public static ISpatialFilter GetQueryFilter(IGeometry pGeometry)
        {
            ISpatialFilter pSpatialFilter = new SpatialFilter();
            pSpatialFilter.Geometry = pGeometry;
            pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

            return pSpatialFilter;
        }

        /// <summary>
        /// 空间过滤选出的结果高亮显示
        /// </summary>
        /// <param name="pFeatureLayer"></param>
        public static void GetSelection(ILayer pFeatureLayer,ISpatialFilter spatialFilter)
        {
            IFeatureSelection featureSelection = pFeatureLayer as IFeatureSelection;
            featureSelection.SelectFeatures(spatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
            featureSelection.SelectionSet.Refresh();
        }
    }
}
